import request from "@/utils/request";

//获取所有资源类别信息
type Common<T> = {
    code: string
    data: T
    mesg: string
    time: string
}
export type ResourceCategory = {
    createBy: string
    createTime: string
    id: number
    name: string
    operatorId: number | null
    selected: boolean
    sort: number
    updateBy: string
    updateTime: string
}
    
export const getAll = () => {
    return request<Common<ResourceCategory>> ({
        method: 'GET',
        url: '/boss/resource/category/getAll',
    })
}
type ResourceCategoryParams = Pick<ResourceCategory, 'name' |'sort'> & { id?: number }
//保存或更新资源类别
export const saveOrderUpdate = (ResourceCategoryInfo: ResourceCategoryParams) =>{
    return request<Common<boolean>> ({
        method: 'POST',
        url: '/boss/resource/category/saveOrderUpdate',
        data: ResourceCategoryInfo
    })
}

//删除资源类别
export const deleteCategory = (id: number) => {
    return request<Common<boolean>> ({
        method: 'DELETE',
        url: `/boss/resource/category/${id}`,
    })
}